<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import storage from "@/utils/storage";

export default {
  mounted() {
    const token = storage.get("token");
    if (token) {
      // 登陆的情况 启动mqtt
      const userInfo = storage.get("userInfo");
      this.$store.dispatch("MQTT_CONNECT");
      setTimeout(() => {
        this.$store.dispatch(
          "MQTT_NEW_TOPIC",
          "mqtt/parking_event/inout" + "/" + userInfo.parkCode
        );
      }, 2000);
      this.$router.push("/home");
    } else {
      this.$router.push("/login");
    }
    window.setMessage = this.setMessage;
  },
  methods: {
    setMessage(row) {
      this.$store.commit("MQTT_CONNECT_ADD_MESSAGE", row);
    },
  },
};
</script>

<style lang="scss"></style>
